<template>
  <div class="gameSearch">
    <el-form
      :inline="true"
      :model="formData"
      class="demo-form-inline searchForm"
      ref="formData"
      style="width:100%"
    >
      <el-form-item>
        <el-select v-model="formData.gameId" filterable placeholder="游戏名">
          <el-option
            v-for="item in options"
            :key="item.id"
            :label="item.gameName"
            :value="item.id"
            style="width:300px"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select v-model="formData.game_audit_id" filterable placeholder="审核状态">
          <el-option
            v-for="item in auditStateOption"
            :key="item.id"
            :label="item.label"
            :value="item.id"
            style="width:130px"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-select v-model="formData.game_plat_id" filterable placeholder="游戏平台类型">
          <el-option
            v-for="item in platTypeOption"
            :key="item.id"
            :label="item.label"
            :value="item.id"
            style="width:130px"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" class="dataSearch" @click="dataSearch(formData)">搜索</el-button>
      </el-form-item>
      <el-form-item>
        <el-button class="addNewgame" type="primary" @click="addGame()">添加新游戏</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { getSearchList } from "@/api/gameManage";
export default {
  data() {
    return {
      formData: {
        game_audit_id: "",
        gameId: "",
        game_plat_id: "",
        page: 1,
        limit: 20
      },
      options: [],
      loading: false,
      auditStateOption: [
        {
          id: 0,
          label: "全部"
        },
        {
          id: 1,
          label: "待提交"
        },
        {
          id: 2,
          label: "审核中"
        },
        {
          id: 3,
          label: "已通过"
        },
        {
          id: 4,
          label: "未过审"
        }
      ],
      platTypeOption: [
        {
          id: 0,
          label: "全部"
        },
        {
          id: 3,
          label: "android"
        },
        {
          id: 4,
          label: "IOS"
        }
      ]
    };
  },
  mounted() {
    getSearchList().then(res => {
      this.options = res.data.list;
    });
  },
  methods: {
    // 查询
    dataSearch() {
      this.$refs.formData.validate(valid => {
        if (valid) {
          this.$store.commit("SET_SEARCH", this.formData);
          this.$emit("searchList", this.formData);
        }
      });
    },
    addGame() {
      this.$emit("showaddgameDialog");
    }
  }
};
</script>
<style lang="scss" scoped>
.gameSearch {
  width: 80%;
}
.el-form-item {
  margin-bottom: 0;
}
.el-button--primary {
  background-color: #409eff;
  border-color: #409eff;
}
.addVideo,
.addNewgame,
.dataSearch {
  padding: 0 15px;
  height: 32px;
  font-size: 13px;
}
.addNewgame {
  // margin-left: 200px;
}
.el-select-dropdown__item {
  white-space: normal;
  height: auto;
}
</style>